<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta content="" name="description" />
    <meta content="webthemez" name="author" />
    <meta http-equiv="pragram" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache, must-revalidate">
    <meta http-equiv="expires" content="0">
    <title>上传任务书</title>
    <!-- Bootstrap Styles-->
    <link href="assets/css/bootstrap.css" rel="stylesheet" />
    <!-- FontAwesome Styles-->
    <link href="assets/css/font-awesome.css" rel="stylesheet" />

    <link href="assets/css/select2.min.css" rel="stylesheet" >
    <link href="assets/css/checkbox3.min.css" rel="stylesheet" >
    <!-- Custom Styles-->
    <link href="assets/css/custom-styles.css" rel="stylesheet" />
    <!-- Google Fonts-->
    <link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
</head>
<body>
<div id="page-wrapper" >



    <!-->
    <div class="header">
        <h1 class="page-header">
            任务书 <small><label id="topicName"></label></small>
        </h1>
    </div>

    <div id="page-inner">

        <button class="btn btn-primary" onclick="dodownload()">
            下载我的任务书
        </button>
        <br>
        <br>
        <br>

        <div class="row">
            <div>
                <div class="panel panel-default">
                    <div class="panel-heading">
                        历史记录（点击下载）
                    </div>
                    <div class="panel-body">
                        <div class="list-group">

                            <div id="text"></div>

                        </div>
                        <div class="col-sm-offset-2 col-sm-10">
                            <a href='' class='btn btn-warning' onclick='' data-toggle='modal' data-target='#myModal'>上传</a>
                        </div>
                    </div>
                </div>

            </div>


        </div>
        <!-- /. PAGE INNER  -->
    </div>
    <!-- /. PAGE WRAPPER  -->
</div>
<!--查看详情-->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="myModalLabel">上传任务书</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" id="form">
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><span style="color:red">*</span>任务书</label>
                        <div class="col-sm-10">
                            <input id="input-sign" type="file" name="file" class="input_text80"></input>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><span style="color:red">*</span>备注</label>
                        <div class="col-sm-10">
                            <textarea type="level" class="form-control" id="notes" placeholder="备注" width="30px"></textarea>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            <button type="button" class="btn btn-default" onclick="dosubmit()">上传</button>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span>关闭</button>
            </div>
        </div>
    </div>
</div>
<!-- /. WRAPPER  -->
<!-- JS Scripts-->
<!-- jQuery Js -->
<script src="assets/js/jquery-1.10.2.js"></script>
<!-- Bootstrap Js -->
<script src="assets/js/bootstrap.min.js"></script>
<!-- Metis Menu Js -->
<script src="assets/js/jquery.metisMenu.js"></script>
<script src="assets/js/select2.full.min.js"></script>

<!-- Custom Js -->
<!--<script src="assets/js/custom-scripts.js"></script>-->
<script src="assets/js/util.js"></script>
<script>
    var user= JSON.parse(sessionStorage.getItem("user"));//将json转换为对象
    console.log(user);
    var topicid=user.topicId;
    var re=getResponse('/topic/selectTopic/'+topicid);
    var r=getResponse('/assignment/find/'+topicid);
    console.log(r);
    document.getElementById("topicName").innerHTML=re.responseJSON.topicName;
    function dodownload() {
        window.location.href='/assignment/downFile/'+r.responseJSON.taskList[0].wordId;
    }
   show();
    function dosubmit(){
        var notes=document.getElementById("notes").value;
        var word=document.getElementById("input-sign").files[0];
        var formData=new FormData();
        formData.append("notes",notes);
        formData.append("word",word);
        formData.append("username",user.username);
        formData.append("realname",user.realname);
        formData.append("topicId",topicid);
        getResponse('/assignment/submitStuWord',formData,'multipart/form-data');
        alert("上传成功！");
    }
    function show() {
        var r=getResponse('/assignment/find/'+topicid);
        var tmp="";
        for(var i=r.responseJSON.stuList.length-1;i>=0;i--){
            if(r.responseJSON.stuList[i].username==user.username) {
                tmp += "<a href='/assignment/downFile/" + r.responseJSON.stuList[i].wordId + "'  class='list-group-item'>"
                    + "<span class='badge'>" + new Date(r.responseJSON.stuList[i].createtime).toLocaleString() + "</span>"
                    + "<i class='fa fa-fw fa-comment'></i>" + r.responseJSON.stuList[i].notes
                    + "</a>";
            }
        }
        document.getElementById("text").innerHTML=tmp;

    }

</script>




</body>
</html>
